#include<stdio.h>
int main()
{
	int i = 1;
	int j = 1;
	int w = 0;
	int max = 0;
	scanf_s("%d %d", &i, &j);
	int n = i > j ? i : j;
	for (w = 1; w <= n; w++)
	{
		if (i % w == 0 && j % w == 0)
		{
			if (max < w)
			{
				max = w;
			}
		}
	}
	printf("%d", max);
	return 0;
}